type idType = string | number;

function printID(id: idType) {
  // 类型缩小
  if (typeof id === "string") {
    console.log(id.length);
  }

  console.log("id" + id);
}

printID(123);
printID("!@3");

type pointType = {
  x: number;
  y: number;
  z?: number;
};

function printPoint(point: pointType) {
  console.log(point.x);
  console.log(point.y);
  console.log(point.z);
}

printPoint({ x: 1, y: 2, z: 2 });
export {};
